﻿using System.IO;
using System.Runtime.Serialization.Json;
using System.Text;

namespace OrbClientCacher
{
	public static class JSONHelper
	{
		public static void Serialize<T>(T obj, Stream s)
		{
			DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));
			serializer.WriteObject(s, obj);
		}

		public static T Deserialize<T>(Stream s)
		{
			DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));
			T obj = (T)serializer.ReadObject(s);
			return obj;
		}
	}
}